package com.wgts.wgts.mvp.view.activity.shopkeeper;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wgts.wgts.R;
import com.wgts.wgts.control.dialog.AbstractCustomDialogFragment;
import com.wgts.wgts.tools.Tools;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class UpdateDialog extends AbstractCustomDialogFragment {
    @BindView(R.id.text_phone)
    TextView textPhone;
    @BindView(R.id.linear_cancle)
    LinearLayout linearCancle;
    @BindView(R.id.linear_ensure)
    LinearLayout linearEnsure;
    Unbinder unbinder;

    private String phone;

    private static final String PHONE_NUMBER = "PHONE_NUMBER";

    @Override
    public View onCreateDialogView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.update_shop_dialog, null);
        unbinder = ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView(){
        phone = getArguments().getString(PHONE_NUMBER);
        textPhone.setText(phone);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    @OnClick({R.id.linear_cancle, R.id.linear_ensure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.linear_cancle:
                dismiss();
                break;
            case R.id.linear_ensure:
                Tools.call(getContext(), phone);
                break;
        }
    }

    public static UpdateDialog getInstance(String phone){
        UpdateDialog updateDialog = new UpdateDialog();
        Bundle bundle = new Bundle();
        bundle.putString(PHONE_NUMBER, phone);
        updateDialog.setArguments(bundle);
        return updateDialog;
    }
}
